package cn.com.sbell.vss.csg.vap;

import org.dom4j.Element;

import cn.com.sbell.vss.Util;
import cn.com.sbell.vss.VssConstants;
import cn.com.sbell.vss.VssException;
import cn.com.sbell.vss.csg.vap.bean.UploadPic;
import cn.com.sbell.vss.csg.vsclient.VsClient;
import cn.com.sbell.vss.csg.vsclient.util.PropertiesHolder;

public class GetUploadPictureConfig extends ProtectedVsCommander{

	@Override
	protected Element executeCommand(VsClient vsClient,
			PropertiesHolder holder, Element root) {
		// TODO Auto-generated method stub
		String deviceId=Util.getTrimParameter(holder.getRequest(), "vsDeviceId");
		UploadPic up=vsClient.getUploadPicture(deviceId);
		if(null==up){
			throw new VssException(VssConstants.CODE_VS_GET_UPLOAD_PICTURE);
		}
		root.addElement("uploadURL").setText(up.getUploadURL());
		root.addElement("enableUploadPicture").setText(String.valueOf(up.isEnableUploadPicture()));
		root.addElement("limitedAmount").setText(String.valueOf(up.getLimitedAmount()));
		root.addElement("limitedResolution").setText(String.valueOf(up.getLimitedResolution()));
		root.addElement("waitingTimeAfterfailure").setText(String.valueOf(up.getWaitingTimeAfterfailure()));
		return root;
	}

}
